<?php 
defined('_JEXEC') or die;

// disable core styles to avoid bs conflict 
OC_Util::$core_styles = array();
if(isDevMode()) {
   OCP\Util::addStyle('company', 'company');
   OCP\Util::addStyle('jobposition', 'jobposition');
   OCP\Util::addScript('jobposition', 'jobposition');
   OCP\Util::addScript('jobposition', 'jobs');
   OCP\Util::addScript('jobposition', 'joblist');
   OCP\Util::addScript('jobposition', 'foldermanage');
   OCP\Util::addScript('jobposition', 'jobactions');
} else {
   OCP\Util::addStyle('static', 'company');
   OCP\Util::addStyle('static', 'jobposition');
   OCP\Util::addScript('static', 'apps/jobpos.min');
}
$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");
OCP\App::setActiveNavigationEntry('jobpos_index');

$jobdir = $_['jobsdir'];
$jobkeyword = JRequest::getString('keyword',null);

$search_sources = JRequest::getVar('source',array('pipapai','51job','zhilian','jiancai','lagou'));

$addtips = false;
$iknow_needconfig = JRequest::getString('iknow_needconfig', null, 'cookie');
$app=JFactory::getApplication();
$publish_date_flag=false;
$renew_date_flag=false;
$num_applied_flag=false;
$highlight_pulish_date=false;
$highlight_renew_date=false;
$highlight_num_applied=false;
$jobpositiondir=$app->getUserState('jobpositiondir','');
if(empty($jobpositiondir['orderby']) || (!empty($jobpositiondir['orderby'])&& $jobpositiondir['orderby'] =='renew')){
   $highlight_renew_date=true;
}
if((!empty($jobpositiondir['orderby'])&& $jobpositiondir['orderby'] =='publish_date')){
   $highlight_pulish_date=true;
}
if(!empty($jobpositiondir['orderby'])&& $jobpositiondir['orderby'] =='num_applied'){
   $highlight_num_applied=true;
}
$orderby=JArrayHelper::getValue($jobpositiondir, 'orderby', 'renew');
$orderdir=strtoupper(JArrayHelper::getValue($jobpositiondir, 'orderdir', 'desc'));
if($orderby=='renew' && $orderdir=='DESC'){
   $renew_date_flag=true;
}
if($orderby=='publish_date' && $orderdir=='DESC'){
   $publish_date_flag=true;
}
if($orderby=='num_applied' && $orderdir=='DESC'){
   $num_applied_flag=true;
}
?>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('jobposition/js', 'jobposition.php'));?>"></script>

 <div class="hr_inner_navigate clearfix" style="box-shadow:none;">
    <?php echo $_['part_position_toptab'];?>
    
    <?php if($jobdir != 'trashed'): ?>
    <div class="hr_breadcrumbs" style=" margin-left:30px;">
       <?php if (PCompanyHelper::checkCRUDPermission()): ?>
       <a href="<?php echo OC_Helper::linkToRoute("jobpos_postjob"); ?>" class="ppp_bluebtn brdb_publish">发布职位</a>
       <?php endif; ?>
    </div>
    <?php endif; ?>
 </div>

 <div class="resume_search fixed_resume_search clearfix">
    <div class="positionselect medium pull-left">
       排序：
       <a href="javascript:;" class='sort <?php echo  $highlight_pulish_date ==true?"highlight_arrow":""; ?>' data-orderby="publish_date" data-orderdir='desc'>按发布时间<i  class="<?php echo $publish_date_flag==true ? 'arrow_down':'arrow_up'; ?>"></i></a>
       <a href="javascript:;" class='sort <?php echo  $highlight_renew_date ==true?"highlight_arrow":""; ?>' data-orderby="renew" data-orderdir='desc' style="margin-left:10px;">按刷新时间<i class="<?php echo $renew_date_flag==true ?'arrow_down':'arrow_up'; ?>" ></i></a>
       <?php if($jobdir != 'trashed'): ?>
       <a href="javascript:;" class='sort <?php echo  $highlight_num_applied ==true?"highlight_arrow":""; ?>' data-orderby="num_applied" data-orderdir='desc' style="margin-left:10px;">按申请人数<i class="<?php echo $num_applied_flag==true ?'arrow_down':'arrow_up'; ?>" ></i></a>
       <?php endif; ?>
    </div>
    
    <?php if($jobdir != 'trashed'): ?>
      <?php if(0):?>
      <div class="separated_line pull-left" style="margin-top:4px;">|</div>
      
      <div class="highsearch pull-left medium" id="highsearch">
         <a href="javascript:;">高级筛选<i></i></a>
      </div>
      <?php endif;?>
    <?php endif; ?>
 </div>
 
 <?php if($jobdir != 'trashed'): ?>
 <form action="<?php echo OC_Helper::linkToRoute('jobpos_search');?>" method="GET" id="jobs_advance_seach">
    <div class="highsearch_wrap">
    <?php if($_['areacheckboxlist']):?>
       <div class="highsearch_eachbox padding medium clearfix" id="area_div">
          <label class="pull-left key">地区：</label>
          <ul style="margin-left:69px; display:block;">
             <li style="padding:0px 0 0 4px;"><input name="area_check" id="area_check" type="checkbox" class="checkall" /></li>
             <?php echo $_['areacheckboxlist'];?>
          </ul>
       </div>
    <?php endif;?>  
      <div class="highsearch_eachbox padding medium clearfix" id="match_div">
         <label class="">匹配条件：</label>
         <ul id="match_search" style="padding-left:3px;">
            <li id="match_all"  name="match_all"><span class='jobposition_search_link' data-match="all">全部</span></li>
            <li class="line">|</li>
            <li id="match_unset" name="match_unset"><span class='jobposition_search_link' data-match="unset">未设</span></li>
            <li class="line">|</li>
            <li id="match_set" name="match_set"><span class='jobposition_search_link' data-match="set">已设</span></li>
         </ul>
      </div>
      <div class="highsearch_eachbox padding medium clearfix" id="sync_div">
         <label class="">同步状态：</label>
         <ul>  
            <li style="padding:0px 0 0 4px;"><input name="sync_check" id="sync_check" type="checkbox" class="checkall" /></li>          
            <?php echo $_['syncheckboxlist'];?>           
         </ul>
      </div>
      <div class="highsearch_eachbox padding medium clearfix" id="sync_div">
         <label class="pull-left key">来源：</label>
         <ul style="margin-left:69px; display:block;"> 
            <li style="padding:0px 0 0 4px;"><input name="source_check" id="source_check" type="checkbox" class="checkall" /></li>          
            <?php echo $_['sourcecheckboxlist'];?>           
         </ul>
      </div>
      <div class="highsearch_eachbox medium clearfix">
         <label class=""></label>
         <div class="selected_bluebtn" id="selectsearch">    
            <input type="hidden" name="jobdir" id="jobdir" value="<?php echo $_['jobsdir'];?>"/>        
            <input type="hidden" name="jobsmatch" id="jobsmatch" value="<?php echo $_['jobsmatch'];?>"/>
            <!--hidden: jobssearch control advance search is show or hide-->
            <input type="hidden" name="jobssearch" id="jobssearch" value="<?php echo JArrayHelper::getValue($jobpositiondir, 'switchsearch', '0');?>" />
            <!--hidden: isalreadysearch check if already submit search button-->
            <input type="hidden" name="isalreadysearch" id="isalreadysearch" value="<?php echo $_['donejobsearch'];?>"/>
            <input type="hidden" name="keyword" id="keyword" value="<?php echo $jobkeyword;?>" />
            <input class="ppp_bluebtn" type="submit" name="submit" value="筛选" />
         </div>
      </div>
      <div class="click_slideup" style="display:none;"></div>
    </div>
 </form>
 <?php endif; ?>
 
<div id="actioninner_wrap" class="<?=empty($_['joblist']) ? '' : 'jobmultiselect'?> <?=(!empty($_['jobssearch']) && $_['jobssearch']=='done') ? 'highslidedown' : ''?>" style="<?=($jobdir == 'trashed') ? 'padding-top:70px;':''?>">

 <div id="headerWrap" class="p_batchactionbox" style="display:<?=empty($_['joblist']) ? 'none' : ''?>">
    <div id="headerName" class="p_action_header">
       <ul class="clearfix">
          <li style="width:580px; border-left:0px;<?=($jobdir=='trashed' ? 'border-right:0px;' : '')?>"><input type="checkbox" class="selectAll" style="margin-top:0px;" autocomplete="off"> <em style="margin-right:20px;">全选</em><span class="pos_tipwords">职位信息</span></li>
          <?php if($jobdir != 'trashed'): ?>
          <li style="width:125px; padding-left:74px;">申请人数</li>
          <li style="width:120px; padding-left:122px; border-right:0px;">推送到第三方网站</li>
          <?php endif; ?>
       </ul>
    </div>
 
    <div id="jobActions" class="p_batchaction_inner medium" style="display: none">
       <input type="checkbox" class="selectAll" style="margin-top:0px;" autocomplete="off">
       <em style="margin-right:20px;">全选</em>
       <span class="selectnum">已选择0 个职位</span>
       <span class="actions_change">
          <?php if($jobdir != 'trashed'): ?>
             <span class="selectedActions" style="display: inline-block;">
                <a class="save" href="javascript:;"><i class="save"></i>收藏</a>
             </span>
             <span class="selectedActions" style="display: inline-block;">
                <a class="unsave" href="javascript:;"><i class="unsave"></i>取消收藏</a>
             </span>
             <span class="selectedActions" style="display: inline-block;">
                <a class="settop" href="javascript:;"><i class="settop"></i>置顶</a>
             </span>
             <span class="selectedActions" style="display: inline-block;">
                <a class="unsettop" href="javascript:;"><i class="unsettop"></i>取消置顶</a>
             </span>
          <?php endif; ?>
          <?php if ($_['permissions'] & OCP\PERMISSION_DELETE): ?>
             <?php if($jobdir == 'trashed'): ?>
                <span class="selectedActions" style="display: inline-block;">
                   <a class="restore" href="javascript:;"><i class="restore"></i>恢复</a>
                </span>
             <?php else: ?>

             <span class="selectedActions" style="display: inline-block;">
                <a class="renew" href="javascript:;"><i class="renew"></i>刷新</a>
             </span>

             <?php if($_['masteruser']): ?>
             <span class="selectedActions" style="display: inline-block;">
                <a class="autorenew" href="javascript:;"><i class="autorenew"></i>自动刷新</a>
             </span>
             <?php endif; ?>
             
             <span class="selectedActions" style="display: inline-block;">
                <a class="delete" href="javascript:;"><i class="delete"></i>删除</a>
             </span>
             <span class="selectedActions" style="display: inline-block;">
                <a class="infolder" href="javascript:;"><i class="infolder"></i>移入文件夹</a>
             </span>
             <?php endif; ?>
          <?php endif; ?>
       </span>
    </div>
 </div>
 
 
 <div id="jobneeds" class="hr_position_set hr_position_indexinner">
 
   <?php if(!empty($_['joblist'])) :?>
   <form action="#" autocomplete="off">
   <?php foreach($_['joblist'] as $i=>$item):
   $last_sync_result = json_decode($item->last_sync_result,true);
   $sourceText = array(
         'pipapai' => '枇杷派云招聘',
         '51job'   => '前程无忧',
         'zhilian' => '智联招聘',
         'lagou'   => '拉勾',
         'jiancai' => '建筑英才'
   );
   $sources_sorted = array("pipapai","51job","zhilian","lagou","jiancai");
   $sources = explode(",", $item->source);
   $sources =array_values(array_intersect($sources_sorted, $sources));
   $job_sync_title="";
   $source_spans =array();
   $j=0;
   $zhilian_renew_title = "";
   $jiancai_renew_title = "";
   $wuyou_renew_title = "";
   $lagou_renew_title = "";

   $zhilian_renew = true;
   $wuyou_renew = true;
   $jiancai_renew = true;
   $lagou_renew = true;

   $active_sources = array();
   
   while(count($sources) > 0) {
      $source = array_shift($sources);
      switch($source) {
         case 'pipapai':
            $job_sync_title .="云招聘：发布时间&nbsp;".JHtml::_('date',$item->publish_date,'Y-m-d H:i:s')."<br>";
            break;
         case '51job':
            if(!empty($last_sync_result['51job']['result'])) {
               $result = $last_sync_result['51job']['result'];
               if($result == 'success' && !empty($last_sync_result['51job']['downtime'])){
                  $job_sync_title .="前程无忧：同步时间&nbsp;".JHtml::_('date',$last_sync_result['51job']['downtime'],'Y-m-d H:i:s')."<br>";
               } elseif($result == 'error'){
                  $job_sync_title .="前程无忧：同步失败<br>";
               } elseif($result == 'syncing'){
                  $job_sync_title .="前程无忧:同步中<br>";
               }
               
            }
            if(isset($last_sync_result['51job']['active'])) {
               $active = $last_sync_result['51job']['active'];
               if($active == 0)
                  $source = '';
            }
            if(!empty($last_sync_result['51job']['renew'])){
               $renew = $last_sync_result['51job']['renew'];
               if($renew == 'success' && !empty($last_sync_result['51job']['renewtime'])){
                  if($last_sync_result['51job']['renewtime'] > $_['starttime']){
                     $wuyou_renew_title = "前程无忧刷新时间：&nbsp;".JHtml::_('date',$last_sync_result['51job']['renewtime'],'Y-m-d')."<br>";
                  }else{
                     $wuyou_renew_title = "前程无忧尚未刷新<br>";
                  }
               }else if($renew == 'error'){
                  $lagou_renew_title = "前程无忧尚未刷新<br>";
               }else{
                  $wuyou_renew = false;
                  $wuyou_renew_title = $renew.'<br>';
               }
            }else{
               $wuyou_renew_title = "前程无忧尚未刷新<br>";
            }
            break;
         case 'zhilian':
            if(!empty($last_sync_result['zhilian']['result'])){
               $result = $last_sync_result['zhilian']['result'];
               if($result == 'success' && !empty($last_sync_result['zhilian']['downtime'])){
                  $job_sync_title .="智联招聘：同步时间&nbsp;".JHtml::_('date',$last_sync_result['zhilian']['downtime'],'Y-m-d H:i:s')."<br>";
               }elseif($result == 'error'){
                  $job_sync_title .="智联招聘：同步失败<br>";
               }elseif($result == 'syncing'){
                  $job_sync_title .="智联招聘:同步中<br>";
               }
            }
            if(isset($last_sync_result['zhilian']['active'])) {
               $active = $last_sync_result['zhilian']['active'];
               if($active == 0)
                  $source = '';
            }
            if(!empty($last_sync_result['zhilian']['renew'])){
               $renew = $last_sync_result['zhilian']['renew'];
               if($renew == 'success' && !empty($last_sync_result['zhilian']['renewtime'])){
                  if($last_sync_result['zhilian']['renewtime'] > $_['starttime']){
                     $zhilian_renew_title = "智联招聘刷新时间：&nbsp;".JHtml::_('date',$last_sync_result['zhilian']['renewtime'],'Y-m-d')."<br>";
                  }else{
                     $zhilian_renew_title = "智联招聘尚未刷新<br>";
                  }
               }else if($renew == 'error'){
                  $lagou_renew_title = "智联招聘尚未刷新<br>";
               }else{
                  $zhilian_renew = false;
                  $zhilian_renew_title = $renew.'<br>';
               }
            }else{
               $zhilian_renew_title = "智联招聘尚未刷新<br>";
            }
            break;
         case 'jiancai':
            if(!empty($last_sync_result['jiancai']['result'])){
               $result = $last_sync_result['jiancai']['result'];
               if($result == 'success' && !empty($last_sync_result['jiancai']['downtime'])){
                  $job_sync_title .="建筑英才：同步时间&nbsp;".JHtml::_('date',$last_sync_result['jiancai']['downtime'],'Y-m-d H:i:s')."<br>";
               }elseif($result == 'error'){
                  $job_sync_title .="建筑英才：同步失败<br>";
               }elseif($result == 'syncing'){
                  $job_sync_title .="建筑英才:同步中<br>";
               }
            }
            if(isset($last_sync_result['jiancai']['active'])) {
               $active = $last_sync_result['jiancai']['active'];
               if($active == 0)
                  $source = '';
            }
            if(!empty($last_sync_result['jiancai']['renew'])){
               $renew = $last_sync_result['jiancai']['renew'];
               if($renew == 'success' && !empty($last_sync_result['jiancai']['renewtime'])){
                  if($last_sync_result['jiancai']['renewtime'] > $_['starttime']){
                     $jiancai_renew_title = "建筑英才刷新时间：&nbsp;".JHtml::_('date',$last_sync_result['jiancai']['renewtime'],'Y-m-d')."<br>";
                  }else{
                     $jiancai_renew_title = "建筑英才尚未刷新<br>";
                  }
               }else if($renew == 'error'){
                  $lagou_renew_title = "建筑英才尚未刷新<br>";
               }else{
                  $jiancai_renew = false;
                  $jiancai_renew_title = $renew.'<br>';
               }
            }else{
               $jiancai_renew_title = "建筑英才尚未刷新<br>";
            }
            break;
         case 'lagou':
            if(!empty($last_sync_result['lagou']['result'])){
               $result = $last_sync_result['lagou']['result'];
               if($result == 'success' && !empty($last_sync_result['lagou']['downtime'])){
                  $job_sync_title .="拉勾：同步时间&nbsp;".JHtml::_('date',$last_sync_result['lagou']['downtime'],'Y-m-d H:i:s')."<br>";
               }elseif($result == 'error'){
                  $job_sync_title .="拉勾：同步失败<br>";
               }elseif($result == 'syncing'){
                  $job_sync_title .="拉勾:同步中<br>";
               }
            }
            if(!empty($last_sync_result['lagou']['renew'])){
               $renew = $last_sync_result['lagou']['renew'];
               if($renew == 'success' && !empty($last_sync_result['lagou']['renewtime'])){
                  if($last_sync_result['lagou']['renewtime'] > $_['starttime']){
                     $lagou_renew_title = "拉勾刷新时间：&nbsp;".JHtml::_('date',$last_sync_result['lagou']['renewtime'],'Y-m-d')."<br>";
                  }else{
                     $lagou_renew_title = "拉勾尚未刷新<br>";
                  }
               }else if($renew == 'error'){
                  $lagou_renew_title = "拉勾尚未刷新<br>";
               }else{
                  $lagou_renew = false;
                  $lagou_renew_title = $renew."<br>";
               }
            }else{
               $lagou_renew_title = "拉勾尚未刷新<br>";
            }
            break;
      }
      
      if(!empty($source)){
         if($j++ < 3) $source_spans[] = $sourceText[$source];
         if($j==4) $source_spans[] = '...';
         array_push($active_sources, $source);
      }
   }

   if(count($source_spans) >0 ):
   if(count(array_intersect($search_sources,$active_sources)) > 0):
   $sourcefrom  =  '<span data-html="true" title="'.(!empty($job_sync_title) ? rtrim($job_sync_title,'、'):"").'">（来源：' . implode('，', $source_spans) . '）</span>';
   ?>
   <div class="jobitem hr_position_each <?php echo $i%2!=0 ? 'hr_position_each_havebg' : ''; ?> clearfix" <?php echo $jobdir != 'trashed' ? '' : 'style="padding:15px;"'; ?> 
      data-id="<?=$item->id?>"
      data-jobtitle="<?=$item->job_title?>"
      data-saved="<?=$item->is_saved?>"
      data-settop="<?=$item->is_settop?>"
      data-type="<?=$jobdir?>"
      data-mime="application/octet-stream"
      data-permissions="<?=$item->permissions?>">
      <div class="hr_position_infoshow pull-left">
         <dl>
            <dt class="jobactions">
               <input type="checkbox" class="check" style="margin-top:-1px;">
               <?php if($jobdir == 'trashed'): ?>
                  <a class="action restore" title="点击恢复" href="javascript:;" data-action="Restore"></a>
                  <!-- <span title="回收站内的职位不可编辑"><b><?php echo $item->job_title; ?></b></span> -->
               <?php else: ?>
                  <?php if(!empty($item->is_saved)): ?>
                     <a class="action unsave" title="点击取消收藏" href="javascript:;" data-action="Unsave" title="取消收藏"></a>
                  <?php else: ?>
                     <a class="action save" title="收藏" href="javascript:;" data-action="Save" title="收藏"></a>
                  <?php endif; ?>
                  <?php if(!empty($item->is_settop)): ?>
                     <a class="action unsettop" title="点击取消置顶" href="javascript:;" data-action="Unsettop"></a>
                  <?php else: ?>
                     <a class="action settop" title="点击置顶" href="javascript:;" data-action="Settop"></a>
                  <?php endif; ?>

                  <?php if(!$jiancai_renew ||  !$zhilian_renew || !$wuyou_renew || !$lagou_renew): ?>
                     <a class="action renew_false <?php echo ($item->permissions & OCP\PERMISSION_DELETE) ? '' : 'unclick'; ?>" data-permission="<?php echo ($item->permissions & OCP\PERMISSION_DELETE) ? 1 : 0; ?>" data-html="true" data-jobid="<?=$item->id ?>" title="<?php echo '本地刷新时间：'.JHtml::_('date',$item->renew,'Y-m-d').'<br>'.$zhilian_renew_title.$wuyou_renew_title.$jiancai_renew_title.$lagou_renew_title; ?>" href="javascript:;"></a>
                  <?php elseif($item->renew > $_['todaystart']): ?>
                     <a class="action renew_success <?php echo ($item->permissions & OCP\PERMISSION_DELETE) ? '' : 'unclick'; ?>" data-permission="<?php echo ($item->permissions & OCP\PERMISSION_DELETE) ? 1 : 0; ?>" data-html="true" data-jobid="<?=$item->id ?>"  title="<?php echo '本地刷新时间：'.JHtml::_('date',$item->renew,'Y-m-d').'<br>'.$zhilian_renew_title.$wuyou_renew_title.$jiancai_renew_title.$lagou_renew_title; ?>" href="javascript:;"></a>
                  <?php else: ?>
                     <a class="action renew <?php echo ($item->permissions & OCP\PERMISSION_DELETE) ? '' : 'unclick'; ?>" data-permission="<?php echo ($item->permissions & OCP\PERMISSION_DELETE) ? 1 : 0; ?>" data-html="true" data-jobid="<?=$item->id ?>" title="点击刷新" href="javascript:;"></a>
                  <?php endif; ?>

                  <?php if($item->permissions & OCP\PERMISSION_DELETE): ?>
                     <a class="action delete" title="将本地职位放入回收站，不影响第三方招聘网站的职位状态" href="javascript:;" data-action="Trash" style="margin-left:0px;"></a>
                  <?php else: ?>
                     <a class="action delete unclick" title="您没有权限将职位放入回收站" href="javascript:;"></a>
                  <?php endif; ?>
               <?php endif; ?>
               <a href="<?php echo OC_Helper::linkToRoute("jobpos_setup", array('id'=>$item->id, 'job_title'=>$item->job_title)); ?>#interview"><?php echo strmaxwordlen($item->job_title,20); ?></a>
               <?php 
               echo $sourcefrom;
               ?>
            </dt>
            
            <?php if($jobdir != 'trashed'): ?>
               <?php if(PCompanyHelper::checkJobManagerPermissions($item->id)): ?>
                  <?php
                     $interviews = json_decode($item->online_interview_requirements);
                  ?>
                  <?php if(!empty($interviews->onlineinterview)): ?>
                     <dd class="interview medium has_interview">
                        <b class="black">招聘设置：</b>
                           <span>
                              <i class='online_interview facetest'></i>&nbsp;<a href="<?php echo OC_Helper::linkToRoute("jobpos_setup", array('id'=>$item->id, 'job_title'=>$item->job_title)); ?>#interview">匹配条件&nbsp;<i class="required_i havedone"></i></a>
                           </span>
                           <span class='gray_arrow'></span>
                           <span>
                              <i class='online_interview penceltest <?php echo !empty($interviews->onlinetest) ? '' : 'gray' ?>'></i>&nbsp;<a href="<?php echo OC_Helper::linkToRoute("jobpos_setup", array('id'=>$item->id, 'job_title'=>$item->job_title)); ?>#onlinetest">线上笔试&nbsp;<i class="required_i <?php echo !empty($interviews->onlinetest) ? 'havedone' : '' ?>"></i></a>
                           </span>
                           <span class='gray_arrow'></span>
                           <?php if(0): ?> 
                           <span><i class='online_interview videotest'></i>&nbsp;<a href='#'>视频面试&nbsp;<i class="required_i havedone"></i></a></span>
                           <span class='gray_arrow'></span>
                           <?php endif; ?>
                           <span>
                              <i class='online_interview persontest <?php echo !empty($interviews->persontest) ? '' : 'gray' ?>'></i>
                              <a href="<?php echo OC_Helper::linkToRoute("jobpos_setup", array('id'=>$item->id, 'job_title'=>$item->job_title)); ?>#persontest">性格评测
                                 <?php echo $item->persontest_shorttitle ? '('.$item->persontest_shorttitle.') ' : ''; ?>
                                 <i class="required_i <?php echo !empty($interviews->persontest) ? 'havedone' : '' ?>"></i>
                              </a>
                              <span class="jobid" style="display:none;"><?=$item->id?></span>
                              <span class="interview_key" style="display:none;">persontest</span>
                           </span>
                     </dd>
                  <? else: ?>
                     <dd class="interview medium no_interview">
                        <b class="black">招聘设置：</b>
                           <span>
                              <i class='online_interview facetest gray'></i>&nbsp;<a href="<?php echo OC_Helper::linkToRoute("jobpos_setup", array('id'=>$item->id, 'job_title'=>$item->job_title)); ?>#interview">匹配条件&nbsp;<i class="required_i undone">
                                 <?php if(!$addtips && !$iknow_needconfig) : ?>
                                 <em class="hr_resumerequiredtip medium iknowtext">
                                    <em>请先配置您的“匹配条件”要求，才可使用其他招聘功能。</em><em data-cookie="7" data-cookiename="iknow_needconfig" class="iknow">我知道了</em>   
                                 </em>
                                 <?php $addtips = true; ?>
                                 <?php endif; ?>
                              </i></a>
                           </span>
                           <span class='gray_arrow'></span>
                           <span><i class='online_interview penceltest gray'></i>&nbsp;线上笔试&nbsp;<i class="required_i"></i></span>
                           <span class='gray_arrow'></span>
                           <?php if(0): ?> 
                           <span><i class='online_interview videotest gray'></i>&nbsp;视频面试&nbsp;<i class="required_i"></i></span>
                           <span class='gray_arrow'></span>
                           <?php endif; ?>
                           <span><i class='online_interview persontest gray'></i>&nbsp;性格评测&nbsp;<i class="required_i"></i></span>
                     </dd>
                  <? endif; ?>
               <?php endif; ?>
            <?php endif; ?>
            
            <dd class="medium" style="color:#999999; font-size:12px;">
            <?php 
            $adminName = '--';
            if(!empty($item->adminusers)) {
               $adminUsers = explode(',', $item->adminusers);
               $adminName = $adminUsers[0];
               if(isset($adminUsers[1])) {
                  $adminName .= '、...';
               }
            }
            ?>
               招聘管理员：<?php echo $adminName; ?> <span>|</span>
               <?php echo ($item->state || $item->city) ? ($item->state == $item->city ? $item->state : $item->state.' '.$item->city) : '地区不限'; ?> <span>|</span>
               <?php echo !empty($item->pos_txt) ? $item->pos_txt : '未设置' ; ?> <span>|</span> 
               <?php echo $item->salary_type ? ( $item->salary_type=='面议' ? '薪资'.JText::_($item->salary_type) : JText::_($item->salary_type)) : '薪资面议' ; ?> <span>|</span>
               发布：<?php echo isNullDate($item->publish_date) ? '0000-00-00':JHtml::_('date',$item->publish_date,'Y-m-d');?> 
               <?php if(!isNullDate($item->renew)):?>
               <span>|</span>
               刷新：<?php echo isNullDate($item->renew) ? '0000-00-00':JHtml::_('date',$item->renew,'Y-m-d');?>
               <?php endif; ?>
            </dd>
         </dl>
      </div>
      
   <?php if($jobdir != 'trashed'): ?>
      <?php
         $offsitesearchurl = OC_Helper::linkToRoute('resumes_offsitesearch').'?new=1&jobid='.$item->id.'&jobtitle='.JFilterOutput::stringURLUnicodeSlug($item->job_title); 
      ?>

      <?php $hasPermission = PCompanyHelper::checkJobManagerPermissions($item->id); ?>
      <div class="hr_position_control <?php echo $hasPermission ? '' :'nopermission'; ?>">
         <?php if($item->num_applied == 0):?>
            <div class="hr_pos_numpeople pull-right medium hr_pos_numpeople_no">
               <a class="fontweight" style="color:#999;"><b><?php echo $item->num_applied; ?></b>人申请</a>
               <a target="_blank" href="<?php echo $offsitesearchurl; ?>" class="p_ositesearchbtn offsitesearch" title="根据此职位条件搜索简历"></a>
            </div>
         <?php else:?>
            <div class="hr_pos_numpeople pull-right medium">
               <a href="<?php echo OC_Helper::linkToRoute("resumes_jobpos", array('jobid'=>$item->id)); ?>">
                  <span class="fontweight"><b><?php echo $item->num_applied; ?></b>人申请</span>
                  <span class="ie9roundedgradient"><span class="fonddetail">查看</span></span>
               </a>
               <a target="_blank" href="<?php echo $offsitesearchurl; ?>" class="p_ositesearchbtn offsitesearch" title="根据此职位条件搜索简历"></a>
               <div class="jobid" style="display:none;"><?=$item->id?></div>
            </div>
         <?php endif;?>

         <?php if(0): ?> 
            <?php if($_['adminuser']): ?>
               <div class="hr_pos_editreq pull-right medium"><a href="#">编辑职位</a></div> 
            <?php endif; ?>
         <?php endif; ?>
      </div>
      <?php 
          $thirdtools_account_info = json_decode($item->last_sync_result,true) ;
          $thirdaccount_51job = empty($thirdtools_account_info['51job']) ? null : $thirdtools_account_info['51job'];
          $thirdaccount_zhilian = empty($thirdtools_account_info['zhilian']) ? null : $thirdtools_account_info['zhilian'];
          $thirdaccount_lagou = empty($thirdtools_account_info['lagou']) ? null : $thirdtools_account_info['lagou'];
          $thirdaccount_jiancai = empty($thirdtools_account_info['jiancai']) ? null : $thirdtools_account_info['jiancai'];
      ?>
      <?php if ($jobdir != 'company'): ?>
      <div class="synchronousaccount <?php echo $hasPermission ? '' :'nopermission'; ?>" data-source="<?=$item->source?>">
         <div class="ie9roundedgradient" style="display:inline-block;">
         <div class="synchronousaction clearfix">
            <div class="group_offsite pull-left">
               <?php 
               $sync_51job_title = '点击此处推送职位信息到前程无忧';
               $sync_51job_text = '前程无忧 ';
               $i_status_51job = '';
               if (isset($thirdaccount_51job['result']) && $thirdaccount_51job['result'] == 'syncing') {
                  $sync_51job_title = '正在推送到前程无忧，请稍后';
                  $sync_51job_text = '推送中... ';
               } elseif (isset($thirdaccount_51job['result']) && $thirdaccount_51job['result'] == 'success') {              
                  if(!empty($thirdaccount_51job['uptime'])){
                     $sync_51job_title = JHtml::_('date', $thirdaccount_51job['uptime'], 'Y-m-d H:i:s') . '推送到前程无忧';                      
                     $i_status_51job = '<i class="ok"></i></a>';
                  }else{
                     $i_status_51job = '<i class=""></i>';
                  }                 
               } elseif (isset($thirdaccount_51job['result']) && $thirdaccount_51job['result'] == 'error') {
                  $sync_51job_title = $thirdaccount_51job['msg'];
                  $i_status_51job = '<i class="notok"></i>';
               } elseif (!isset($thirdaccount_51job['result'])){
                  $i_status_51job = '<i class=""></i>';
               }
               ?>
               <a href="javascript:;" class="account51job <?=($item->admin && isset($thirdaccount_51job['result']) && $thirdaccount_51job['result'] == 'syncing' ? 'unclick' : '')?>" data-placement="left" title="<?=$sync_51job_title?>" data-type="51job" data-syncaction='editjob' data-jobid="<?=$item->id?>" data-result="<?=isset($thirdaccount_51job['result'])?$thirdaccount_51job['result']:''?>">
                   <?="<em>".$sync_51job_text."</em>".$i_status_51job?>
               </a>
               
               <?php 
               $sync_zhilian_title = '点击此处推送职位信息到智联招聘';
               $sync_zhilian_text = '智联招聘 ';
               $i_status_zhilian = '';
               if (isset($thirdaccount_zhilian['result']) && $thirdaccount_zhilian['result'] == 'syncing') {
                  $sync_zhilian_title = '正在推送到智联招聘，请稍后';
                  $sync_zhilian_text = '推送中... ';
               } elseif (isset($thirdaccount_zhilian['result']) && $thirdaccount_zhilian['result'] == 'success') {
                  if(!empty($thirdaccount_zhilian['uptime'])){
                     $sync_zhilian_title = JHtml::_('date', $thirdaccount_zhilian['uptime'], 'Y-m-d H:i:s') . '推送到智联招聘';
                     $i_status_zhilian = '<i class="ok"></i></a>';                   
                  }else{
                     $i_status_zhilian = '<i class=""></i>';
                  }
                  
               } elseif (isset($thirdaccount_zhilian['result']) && $thirdaccount_zhilian['result'] == 'error') {
                  $sync_zhilian_title = $thirdaccount_zhilian['msg'];
                  $i_status_zhilian = '<i class="notok"></i>';
               } elseif (!isset($thirdaccount_zhilian['result'])) {
                  $i_status_zhilian = '<i class=""></i>';
               }
               ?>
               <a href="javascript:;" class="accountzhilian <?=($item->admin && isset($thirdaccount_zhilian['result'])  && $thirdaccount_zhilian['result'] == 'syncing' ? 'unclick' : '')?>" data-placement="left" title="<?=$sync_zhilian_title?>" data-type="zhilian" data-syncaction='editjob' data-jobid="<?=$item->id?>" data-result="<?=isset($thirdaccount_zhilian['result'])?$thirdaccount_zhilian['result']:''?>">
                  <?="<em>".$sync_zhilian_text."</em>".$i_status_zhilian?>
               </a>

               <?php 
               $sync_lagou_title = '点击此处推送职位信息到拉勾';
               $sync_lagou_text = '拉勾';
               $i_status_lagou = '';
               if (isset($thirdaccount_lagou['result']) && $thirdaccount_lagou['result'] == 'syncing') {
                  $sync_lagou_title = '正在推送到拉勾，请稍后';
                  $sync_lagou_text = '推送中... ';
               } elseif (isset($thirdaccount_lagou['result']) && $thirdaccount_lagou['result'] == 'success') {
                  if(!empty($thirdaccount_lagou['uptime'])){
                     $sync_lagou_title = JHtml::_('date', $thirdaccount_lagou['uptime'], 'Y-m-d H:i:s') . '推送到拉勾';
                     $i_status_lagou = '<i class="ok"></i></a>';
                  }else{
                     $i_status_lagou = '<i class=""></i>';
                  }
               } elseif (isset($thirdaccount_lagou['result']) && $thirdaccount_lagou['result'] == 'error') {
                  $sync_lagou_title = $thirdaccount_lagou['msg'];
                  $i_status_lagou = '<i class="notok"></i>';
               } elseif (!isset($thirdaccount_lagou['result'])) {
                  $i_status_lagou = '<i class=""></i>';
               }
               ?>
               <a href="javascript:;" class="accountlagou <?=($item->admin ? '' : 'unclick')?>" data-placement="left" title="<?=$sync_lagou_title?>" data-type="lagou" data-syncaction='editjob' data-jobid="<?=$item->id?>" data-result="<?=isset($thirdaccount_lagou['result'])?$thirdaccount_lagou['result']:''?>">
                  <?="<em>".$sync_lagou_text."</em>".$i_status_lagou?>
               </a>

               <?php 
               $sync_jiancai_title = '点击此处推送职位信息到建筑英才';
               $sync_jiancai_text = '建筑英才';
               $i_status_jiancai = '';
               if (isset($thirdaccount_jiancai['result']) && $thirdaccount_jiancai['result'] == 'syncing') {
                  $sync_jiancai_title = '正在推送到建筑英才，请稍后';
                  $sync_jiancai_text = '推送中... ';
               } elseif (isset($thirdaccount_jiancai['result']) && $thirdaccount_jiancai['result'] == 'success') {
                  if(!empty($thirdaccount_jiancai['uptime'])){
                     $sync_jiancai_title = JHtml::_('date', $thirdaccount_jiancai['uptime'], 'Y-m-d H:i:s') . '推送到建筑英才';
                     $i_status_jiancai = '<i class="ok"></i></a>';
                  }else{
                     $i_status_jiancai = '<i class=""></i>';
                  }                
               } elseif (isset($thirdaccount_jiancai['result']) && $thirdaccount_jiancai['result'] == 'error') {
                  $sync_jiancai_title = $thirdaccount_jiancai['msg'];
                  $i_status_jiancai = '<i class="notok"></i>';
               } elseif (!isset($thirdaccount_jiancai['result'])) {
                  $i_status_jiancai = '<i class=""></i>';
               }
               ?>
               <a href="javascript:;" class="accountjiancai <?=($item->admin && isset($thirdaccount_jiancai['result'])  && $thirdaccount_jiancai['result'] == 'syncing'? 'unclick' : '')?>" data-placement="left" title="<?=$sync_jiancai_title?>" data-type="jiancai" data-syncaction='editjob' data-jobid="<?=$item->id?>" data-result="<?=isset($thirdaccount_jiancai['result'])?$thirdaccount_jiancai['result']:''?>">
                  <?="<em>".$sync_jiancai_text."</em>".$i_status_jiancai?>
               </a>

               <?php if(0): ?>
               <div class="otheroffsite pull-left" style="display:none;">
               <a data-placement="left" class="accountyingcai " href="javascript:;"title="点击此处推送职位信息到中华英才">
                  <em>中华英才</em><i class=""></i>
               </a>
               <a data-placement="left" class="accountganji " href="javascript:;"title="点击此处推送职位信息到赶集网">
                  <em>赶集</em><i class=""></i>
               </a>
               <a data-placement="left" class="account58tj " href="javascript:;"title="点击此处推送职位信息到58同城">
                  <em>58同城</em><i class=""></i>
               </a>
               </div>
               <div class="offsitesetting pull-left" style="display:none;"><a href="#">设置</a></div>
               <?php endif; ?>
            </div>
            
            <?php if(0): ?>
            <a class="showmoreoffsite medium pull-right" href="javascript:;">更多<em class="up down"></em></a>
            <?php endif; ?>
         </div>
         </div>
      </div>
      <?php endif; ?>
      
      <?php if(0): ?>
      <div class="sitesynchronous_news medium">2个推送成功，1个推送失败 <a href="javascript:;">×</a></div>
      <?php endif; ?>
      
   <?php endif; ?>
   </div>
   <?php endif;?>
   <?php endif;?>
   <?php endforeach; ?>
   <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
   <div id="pagination" style="padding-top:0px;<?php echo ($_['pagination']->pagesTotal > 1) ? '' : 'display:none;'?>">
      <?php echo $_['pagination']->getListFooter(); ?>
   </div>

   </form>

   <?php else: ?>
   <div class="hr_position_nodata">
      <div class="hr_netaddress">
         <?php 
         $noJobText = '';
         switch ($jobdir) {
            case 'active':
               $noJobText = '暂无发布中的职位';
               break;
            case 'closed':
               $noJobText = '暂无关闭的职位';
               break;
            case 'expired':
               $noJobText = '暂无过期的职位';
               break;
            case 'company':
               $noJobText = '暂无公司职位';
               break;
            default:
               $noJobText = '暂无职位信息';
               break;
         }
         ?>
         <span class="nodata_tip yahei large"><?=$noJobText?></span><br/>
         <?php if (!empty($jobdir) && $jobdir == 'all' && PFactory::isMasterUser()): ?>
         <span class="hr_net_config">完成职位同步后，云招聘会自动同步职位信息并接收简历。</span>
         <a href="<?php echo OC_Helper::linkToRoute("company_synchronousinfo"); ?>" id="" style="display:inline-block;">立即同步</a>
         <?php endif; ?>
      </div>
   </div>
   
   <div class="hr_net_tipdialog popup" id="hr_howtoconfig" style="width:260px; display:none; top:auto; left:auto;">
      <div class="hr_net_point"></div>
      <div class="closediv"></div>
   	<div class="hr_net_tipcontent">
   	   <p>1. 登录<a href="http://ehire.51job.com/MainLogin.aspx" target="_blank">前程无忧</a> / <a href="http://hr.zhaopin.com/hrclub/index.html" target="_blank">智联招聘</a> / <a href="http://ent.buildhr.com/login" target="_blank">建筑英才</a></p>
         <p>2. 进入已发布的职位详情页</p>
         <p class="clearfix"><em class="pull-left">3.</em> <em class="blockstyle">找到<b>简历接收方式</b>，填写云招聘邮箱<br/>地址 <b class="yellowcolor"><?php echo PCompanyHelper::getResumeForwardEmail() ?></b></em></p>
         <p class="textright"><a href="<?=JURI::base()?>helps/doc/product/resumeforward_51job.html">查看详细帮助</a></p>
      </div>
   </div>
   <?php endif; ?>
 </div>
 
</div>

<?=$_['part_position_modal']?>

<div id="accountsetdialog_51job" class="modal hide accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<div id="accountsetdialog_zhilian" class="modal hide accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<div id="accountsetdialog_jiancai" class="modal hide accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<div id="accountsetdialog_lagou" class="modal hide accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<input type="hidden" id="orderBy" value="<?php echo $_['orderBy']; ?>" />
<input type="hidden" id="orderDir" value="<?php echo $_['orderDir']; ?>" />

<div class="modal hide fade refreshtip_dialog popup" id="refreshtip_dialog">
</div>

<div id="renew_syncto" data-autosetresult="" data-syncto="" ></div>


<!-- 职位管理自动刷新确认dialog -->
<div class="modal hide fade" id="autorenewdialog">
</div>

<!-- 职位管理自动刷新成功dialog -->
<div class="modal hide fade autorenew_dialog" id="">
</div>
